<%-- 
    Document   : search_result_content
    Created on : 18-Jul-2013, 22:02:16
    Author     : MrMAD
--%>

<%@page import="mybean.Book"%>
<%@page import="java.util.List"%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
        <title>Book Store</title>
        <meta name="keywords" content="Book Store" />
        <meta name="description" content="Hoa Lac Book Store" />
        <link href="MyCss/mycss.css" rel="stylesheet" type="text/css" />
        <style>
            h1 {
                font-size: 14px;
                color: #cbc750;
                padding: 0px 10px 5px 200px;
                margin: 0px 20px 10px 20px;  
            }
        </style>
    </head>
    <body>
        <script src="js/jquery.min.js"></script>
        <script src="js/imtech_pager.js"></script>
        <script src="js/buy.js"></script>

        <jsp:useBean id="bookList" class="mybean.DBProcess"/>

        <div id="content">                        
            <%
                String keyword = request.getParameter("keyword");
                String searchfor = request.getParameter("searchfor");                
                List<Book> searchResult = bookList.search(keyword, searchfor);
                if(searchResult.isEmpty()){
                    out.println("<br><h1>No book found.</h1><br>");
                }else{
            %>
            <c:forEach var="bookItem" items="<%= bookList.search(keyword, searchfor) %>">
                <div class="z">
                    <div id="templatemo_content_right">
                        <div class="templatemo_product_box">                            
                            <h1><a href="detail.jsp?bookID=${bookItem.bookID}">${bookItem.bookTitle} <span>(by ${bookItem.author})</span></a></h1>
                            <a href="detail.jsp?bookID=${bookItem.bookID}"><img alt="image" src="${bookItem.cover}"/></a>
                            <div class="product_info">
                                <p>${bookItem.summary}</p>

                                <div id="buttonNprice">
                                    <h3>Publisher: ${bookItem.publisher}</h3>
                                    <h3>PRICE: ${bookItem.price}</h3>
                                    <div id="button">
                                        <div class="buy_now_button" onclick="buy(${bookItem.bookID})"><a>Add to cart</a></div>
                                        <div class="detail_button"><a href="detail.jsp?bookID=${bookItem.bookID}">Detail</a></div>
                                    </div>
                                </div>
                            </div>                        

                        </div>                               
                        <div class="cleaner_with_height">&nbsp;</div>  
                    </div> <!-- end of content right -->
                </div>  
            </c:forEach>
        </div>         
        <div id="pagingControls"></div>

        <script type="text/javascript">
            var pager = new Imtech.Pager();
            $(document).ready(function() {
                pager.paragraphsPerPage = 3; // set amount elements per page
                pager.pagingContainer = $('#content'); // set of main container
                pager.paragraphs = $('div.z', pager.pagingContainer); // set of required containers
                pager.showPage(1);
            });
        </script>        
        <%
            }
        %>
    </body>
</html>
